<template>
    <div class="my-upload">
        <!-- 495px -->

        <el-radio-group size="mini" class="re-radio" v-model="auditbj">
            <el-radio-button label="0">
                <span>
                    未审核
                    <span v-if="tableDataNo">({{tableDataNo.length}})</span>
                </span>
            </el-radio-button>
            <el-radio-button label="1">
                <span>
                    已审核
                    <span v-if="tableDataEd">({{tableDataEd.length}})</span>
                </span>
            </el-radio-button>
        </el-radio-group>

        <div v-show="auditbj== '0'">
            <upload-table :tableData="tableDataNo" :pgData="pgDataNo" @clickTitle="clickTitle" @editHandler="editHandler" @delHandler="delHandler">
            </upload-table>
            <div class="pagination" v-show="tableDataNo.length >0 ">
                <my-pagination ref="pageNo" v-model="tableDataNo" :action="`${$store.state.api.tbUrl}/center/uploadlist.json`" :loading.sync="loading"
                    :search="pgDataNo" :autoShow="false"></my-pagination>
            </div>
        </div>

        <div v-show="auditbj== '1'">
            <upload-table :tableData="tableDataEd" :pgData="pgDataEd" @clickTitle="clickTitle" @editHandler="editHandler" @delHandler="delHandler">
            </upload-table>
            <div class="pagination" v-show="tableDataEd.length >0 ">
                <my-pagination ref="pageEd" v-model="tableDataEd" :action="`${$store.state.api.tbUrl}/center/uploadlist.json`" :loading.sync="loading"
                    :search="pgDataEd" :autoShow="false"></my-pagination>
            </div>
        </div>

        <el-dialog :visible.sync="dialogVisible" class="re-dialog" title="编辑文件" width="500px">
            <form-page v-if="dialogVisible" :data="form" @cancle="dialogClose" @addSuccess="addSuccess"></form-page>
        </el-dialog>
    </div>
</template>

<script>
import InfoCard from '../../components/info-card.vue';
import EmptyList from '@components/sys/empty-list';
import formPage from '@/pages/document/formPage.vue';
import uploadTable from './upload-table.vue';

export default {
    components: { InfoCard, EmptyList, formPage, uploadTable },
    data() {
        return {
            activeName: '1',
            radio1: '1',
            loading: false,
            tableData: [],
            tableDataNo: [],
            tableDataEd: [],

            auditbj: '0', //0 待审核， 1 已审核
            pgDataNo: {
                pagesize: 9,
                sortname: 'addtime',
                auditbj: '0',
                doctypecode: 'tou_biao_fang_an',
            },
            pgDataEd: {
                pagesize: 9,
                sortname: 'addtime',
                auditbj: '1',
                doctypecode: 'tou_biao_fang_an',
            },

            total: 0,
            dialogVisible: false,
            form: [],
        };
    },
    watch: {},
    methods: {
        //点击标题，查看详情
        clickTitle(row) {
            let routeData = this.$router.resolve({
                path: `center/download/detail?guid=${row.guid}`,
            });
            // let routeData = this.$router.resolve({
            //     path: `center/download/components/upload-components/detail/?guid=${row.guid}`,
            // });
            window.open(routeData.href, '_blank');
        },

        // 删除 
        delHandler(val) {
            showConfirm('请确认是否删除此条数据', 'warning', () => {
                this.$post(
                    `${this.$store.state.api.webUrl}/tbfaupload/deletedoc.json`,
                    {
                        guid: val.guid,
                    },
                    (data) => {
                        showMsg('删除成功', 'success');
                        this.getData();
                    }
                );
            });
        },
        // 编辑
        editHandler(val) {
            // 获取详情数据
            this.$get(
                `${this.$store.state.api.webUrl}/tbfaupload/detail.json`,
                {
                    guid: val.guid,
                },
                (data) => {
                    this.form = data;
                    this.dialogVisible = true;
                }
            );
        },

        // 修改成功 请求数据
        addSuccess() {
            this.getData();
        },
        dialogClose() {
            this.dialogVisible = false;
        },
        // 数据变化，重新获取数据
        getData() {
            this.$refs.pageNo.queryData();
            this.$refs.pageEd.queryData();
        },
    },
};
</script>



<style lang="scss" scoped>
.el-table::before {
    height: 0;
}
@import '@css/var.scss';
.my-upload {
    .re-radio {
        margin-bottom: 14px;
        span {
            font-size: 14px;
        }
    }

    .empty {
        height: 395px;
        text-align: center;
        line-height: 250px;
        color: #606266;
    }

    .name {
        cursor: pointer;
        &:hover {
            color: $primaryColor;
        }
    }
    .title {
        font-weight: 600;
    }
    .items {
        // margin-top: 20px;

        &:first-child {
            margin-top: 0;
        }
    }
    .pagination {
        display: flex;
        justify-content: right;
    }
    .my-btn {
        color: #606266;
        padding: 0;
        &:hover {
            color: $primaryColor;
        }
    }

    .re-dialog {
        ::v-deep {
            .el-dialog__header {
                padding: 20px 20px 20px 30px;
            }

            .el-dialog__body {
                padding: 10px 30px;
            }
        }
        ::v-deep {
            .el-dialog {
                border-radius: 6px;
                overflow: hidden;
            }
            .el-dialog__header {
                font-weight: bold;
                .el-dialog__headerbtn {
                    z-index: 10;
                }
            }
        }
    }

    // }
}
</style> 